package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.common.annotion.log.BussinessLog;
import com.stylefeng.guns.common.constant.Dict;
import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.common.persistence.dao.CollectComplainNewsMapper;
import com.stylefeng.guns.common.persistence.model.CollectComplainNews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * 投诉信息控制器
 *
 * @author fengshuonan
 * @Date 2018-10-23 10:29:11
 */
@Controller
@RequestMapping("/collectComplainNews")
public class CollectComplainNewsController extends BaseController {

    private String PREFIX = "/system/collectComplainNews/";

    @Autowired
    CollectComplainNewsMapper collectComplainNewsMapper;
    /**
     * 跳转到投诉信息首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "collectComplainNews.html";
    }

    /**
     * 跳转到添加投诉信息
     */
    @RequestMapping("/collectComplainNews_add")
    public String collectComplainNewsAdd() {
        return PREFIX + "collectComplainNews_add.html";
    }

    /**
     * 跳转到修改投诉信息
     */
    @RequestMapping("/collectComplainNews_update/{collectComplainNewsId}")
    public String collectComplainNewsUpdate(@PathVariable Integer collectComplainNewsId, Model model) {
        return PREFIX + "collectComplainNews_edit.html";
    }

    /**
     * 获取投诉信息列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        List<CollectComplainNews> collectComplainNewses = collectComplainNewsMapper.selectList(null);
        return collectComplainNewses;
    }

    /**
     * 新增投诉信息
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add() {
        return super.SUCCESS_TIP;
    }

    /**
     * 删除投诉信息
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
     @BussinessLog(value = "删除投诉信息",key = "collectComplainNewsId",dict = Dict.DeleteDict)
    public Object delete(@RequestParam long collectComplainNewsId) {
        collectComplainNewsMapper.deleteById(collectComplainNewsId);
        return SUCCESS_TIP;
    }


    /**
     * 修改投诉信息
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update() {
        return super.SUCCESS_TIP;
    }

    /**
     * 投诉信息详情
     */
    @RequestMapping(value = "/detail")
    @ResponseBody
    public Object detail() {
        return null;
    }
}
